package useTask.hbaseTask;

import java.io.IOException;
import java.util.Scanner;

public class Main {
    private static String tableName; // 表名
    private static String rowKey; // 行建
    private static String family; // 列住
    private static String column; // 列
    private static String value; // 值
    private static String time; // 值

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("0.增加修改数据 1.删除数据 2.查询数据 3.结束程序");
            System.out.println("情选择功能>> ");
            int chose = sc.nextInt();

            if (chose==3) break;

            switch (chose) {
                case 0:
                    System.out.println("请输入表名：");
                    tableName = sc.next();
                    System.out.println("请输入行建：");
                    rowKey = sc.next();
                    System.out.println("请输入列住：");
                    family = sc.next();
                    System.out.println("请输入列：");
                    column = sc.next();
                    System.out.println("请输入值：");
                    value = sc.next();
                    insertHbase.insert(tableName, rowKey, family, column, value);
                    System.out.println("添加or修改 >> 成功");
                    break;
                case 1:
                    System.out.println("请选择数据删除模式：0-删除指定行，1-删除指定rowKey的列数据，2-删除指定行指定时间戳的数据");
                    int chose2 = sc.nextInt();
                    switch (chose2) {
                        case 0:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            deleteHbase.deleteAll(tableName, rowKey);
                            System.out.println("删除成功");
                            break;
                        case 1:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            System.out.println("请输入列住：");
                            family = sc.next();
                            System.out.println("请输入列：");
                            column = sc.next();
                            deleteHbase.delete(tableName, rowKey, family, column);
                            System.out.println("删除成功");
                            break;
                        case 2:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            System.out.println("请输入列住：");
                            family = sc.next();
                            System.out.println("请输入列：");
                            column = sc.next();
                            System.out.println("请输入时间戳：");
                            time = sc.next();
                            deleteHbase.delete(tableName, rowKey, family, column, time);
                            System.out.println("删除成功");
                            break;
                    }
                    break;
                case 2:
                    System.out.println("请选择数据查询模式：0-查询指定行，1-删除指定rowKey的列族数据，2-删除指定行指定列的数据");
                    int chose3 = sc.nextInt();
                    switch (chose3) {
                        case 0:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            getHbase.getData(tableName,rowKey);
                            break;
                        case 1:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            System.out.println("请输入列住：");
                            family = sc.next();
                            getHbase.getData(tableName,rowKey,family);
                            break;
                        case 2:
                            System.out.println("请输入表名：");
                            tableName = sc.next();
                            System.out.println("请输入行建：");
                            rowKey = sc.next();
                            System.out.println("请输入列住：");
                            family = sc.next();
                            System.out.println("请输入列：");
                            column = sc.next();
                            getHbase.getData(tableName, rowKey, family, column);
                            break;
                    }
                    break;
                default:
                    System.out.println("其他功能待扩展");
                    break;
            }
        }
    }
}
